package cn.itcast.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.itcast.pojo.User;

@Controller
@RequestMapping("hello3")
@RestController//作用：将该类中所有的的方法的返回值，都响应为json格式的数据
public class Hello3Controller {

	@RequestMapping("demo1")
	public List<User> demo1(){
		List<User> list = new ArrayList<User>();
		for (int i = 0; i < 20; i++) {
			User user = new User();
			user.setId(i+1l);
			user.setUsername("admin"+i);
			user.setName("用户"+i);
			user.setAge(18+i);
			list.add(user);
		}
		return list;
	}
	
	@RequestMapping("demo2")
	public String demo2(Model model){
		
		model.addAttribute("msg", "测试");
		return "hello";
	}
	
}
